package scrolls;

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class Input implements KeyListener, ActionListener, MouseListener, MouseMotionListener
{
	Player player;
	HUD HUD;
	//	static int mouseClickLocationX = 0, mouseClickLocationY = 0, mouseLocationX = 0, mouseLocationY = 0;
	static Point mouseLocation, mouseClickLocation;

	static JFrame frame = new JFrame("The Younger Scrolls");

	public Input()
	{
		player = new Player();
	}

	public void keyPressed(KeyEvent e)
	{
		player.keyPressed(e);
	}

	public void keyReleased(KeyEvent e)
	{
		player.keyReleased(e);

		if (Inventory.openInvent)
		{
			if (e.getKeyCode() == KeyEvent.VK_E)
			{
				Inventory.openInvent = false;
			}
		} else if (e.getKeyCode() == KeyEvent.VK_E)
		{
			Inventory.openInvent = true;
		}
	}

	public void keyTyped(KeyEvent e)
	{
	}

	public void actionPerformed(ActionEvent e)
	{
		ImageIcon img = new ImageIcon("src/res/icon.png");
		frame.add(new Draw());
		Frame.menu.dispose();
		frame.setSize(Frame.width, Frame.height);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setIconImage(img.getImage());
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
	}

	public static Rectangle mouseRect()
	{
		return new Rectangle(mouseLocation.x, mouseLocation.y, 10, 10);
	}

	public void mouseClicked(MouseEvent e)
	{
	}

	public void mouseEntered(MouseEvent e)
	{
	}

	public void mouseExited(MouseEvent e)
	{
	}

	public void mousePressed(MouseEvent e)
	{
	}

	public void mouseReleased(MouseEvent e)
	{
		mouseClickLocation = e.getPoint();
		Inventory.openInv();
	}

	public void mouseDragged(MouseEvent e)
	{
	}

	public void mouseMoved(MouseEvent e)
	{
		mouseLocation = e.getPoint();
	}
}
